#pragma once

#include "AcceptCallAction.h"

#include "OutputPin.h"

namespace uml {

AcceptCallAction::AcceptCallAction(const QString& umlType)
    : AcceptEventAction(umlType) {}

void AcceptCallAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    AcceptEventAction::fromJson(json, errorList);
    returnInformation_ = JsonSerializable::create<OutputPin>(json.value("returnInformation"), errorList);

}

void AcceptCallAction::toJson(QJsonObject& json) {
    AcceptEventAction::toJson(json);
    if (returnInformation_) {
        QJsonObject returnInformation_json;
        returnInformation_->toJson(returnInformation_json);
        json.insert("returnInformation", returnInformation_json);
    }
}

/// <summary>
/// returnInformation getter
/// An OutputPin where a value is placed containing sufficient information to
/// perform a subsequent ReplyAction and return control to the caller. The contents
/// of this value are opaque. It can be passed and copied but it cannot be
/// manipulated by the model.
/// </summary>
shared_ptr<OutputPin> AcceptCallAction::returnInformation() const {
    return returnInformation_;
}

/// <summary>
/// returnInformation setter
/// An OutputPin where a value is placed containing sufficient information to
/// perform a subsequent ReplyAction and return control to the caller. The contents
/// of this value are opaque. It can be passed and copied but it cannot be
/// manipulated by the model.
/// </summary>
void AcceptCallAction::setReturnInformation(shared_ptr<OutputPin> value) {
    returnInformation_ = value;
}

} // namespace uml
